package com.sc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sc.mapper.UserMapper;
import com.sc.pojo.User;
import com.sc.service.FriendsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 陈远坤
 */
@Service
@Transactional
public class FriendsServiceImpl implements FriendsService {
    @Autowired
    UserMapper mapper;
    @Override
    public PageInfo<User> selectFriends(Integer pageNum, Integer pageSize, User u) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = mapper.selectFrends(u);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<User> selectFriendsByLikes(Integer pageNum, Integer pageSize, User u, String likes) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = mapper.selectFrendsByPhone(u,likes);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<User> selectAllfs(Integer pageNum, Integer pageSize, User u) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = mapper.selectAllfs(u);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<User> selectAllfsByLikes(Integer pageNum, Integer pageSize, User u, String likes) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = mapper.selectAllfsByLikes(u,likes);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<User> selectHmd(User u, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = mapper.selectHmd(u);
        return new PageInfo<>(list);
    }

    @Override
    public PageInfo<User> selectHmdByLikes(User u, Integer pageNum, Integer pageSize, String likes) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = mapper.selectHmdByLikes(u,likes);
        return new PageInfo<>(list);
    }
}
